package cn.ithers.blog.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;

/**
 * @Author: zhanghuan
 * @date: 2020/10/26 12:02
 * @description:
 */
@Data
@Document(indexName = "blog", type = "article")
public class EsArticle implements Serializable {

    private static final long serialVersionUID = -1L;

    @Id
    private String id;
    @Field(type = FieldType.Keyword)
    private String title;

    private String userId;

    private String userAvatar;

    private String userName;


    @Field(type = FieldType.Keyword)
    private String categoryId;

    @Field(type = FieldType.Keyword)
    private String content;

    //0表示富文本，1表示markdown
    private String type;

    private String cover;

    //0表示删除，1.表示已经发布，2表示草稿，3置顶
    private String state = "1";

    @Field(type = FieldType.Keyword)
    private String summary;

    private String label;

    private long viewCount = 0L;

    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 所以可搜索信息
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String all;

}
